const formatTime = date => {
  const year = date.getFullYear()
  const month = date.getMonth() + 1
  const day = date.getDate()
  const hour = date.getHours()
  const minute = date.getMinutes()
  const second = date.getSeconds()

  return [year, month, day].map(formatNumber).join('/') + ' ' + [hour, minute, second].map(formatNumber).join(':')
}
const app = getApp();
const user = wx.getStorageSync("user");
const base_url = app.globalData.base_url;

const formatNumber = n => {
  n = n.toString()
  return n[1] ? n : '0' + n
}
const zero = function (n) {
  return n < 10 ? '0' + n : n
}
const strchangdu = function(str){
  var len = 0;
  for (var i = 0; i < str.length; i++) {
    var c = str.charCodeAt(i);
    //单字节加1 
    if ((c >= 0x0001 && c <= 0x007e) || (0xff60 <= c && c <= 0xff9f)) {
      len++;
    }
    else {
      len += 2;
    }
  }
  return len;
}

module.exports = {
  formatTime: formatTime,
  zero: zero
}
